/**
 ** @author:	   浓咖啡
 ** @date:	   2016.6.23
 ** @brief:      主程序
 */
 
#include "data_global.h"
#include "link_list.h"



extern pthread_cond_t cond_analysis;
extern pthread_cond_t cond_refresh;

extern pthread_mutex_t mutex_linklist;
extern pthread_mutex_t mutex_analysis;
extern pthread_mutex_t mutex_refresh;

extern linklist p;
extern int volume;
extern int rw;

pthread_t id_analysis, id_transfer, id_refresh;

extern void *pthread_analysis (void *);			//数据解析线程
extern void *pthread_transfer (void *);			//数据接收线程

int main(int argc, char **argv)
{
	p = create_empty_linklist ();
	volume = 5;
	rw = 0;
	pthread_mutex_init (&mutex_analysis, NULL);  //数据包分析线程锁
	pthread_mutex_init (&mutex_refresh, NULL);  //数据刷新线程锁
	pthread_mutex_init (&mutex_linklist, NULL);  //数据包线程锁

	pthread_cond_init (&cond_analysis, NULL);  //唤醒分析线程使用
	pthread_cond_init (&cond_refresh, NULL);  //唤醒刷新线程使用

	pthread_create (&id_analysis, 0, pthread_analysis, NULL);
	pthread_create (&id_transfer, 0, pthread_transfer, NULL);

	pthread_join (id_analysis, NULL);
	pthread_join (id_transfer, NULL);
    free(p);    
    return 0;
}
